import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [{
    path: '/',
    name:'首页',
    component: () => import('../views/Home.vue'),
  },
  //搜索
  {
    path: '/search',
    component: () => import('../views/Search.vue'),
    redirect: '/home',
  },
  //党建详情
  {
    path: '/constructionDetail/:id?',
    component: () => import('../views/details/ConstructionDetail.vue'),
  },
  //协会详情
  {
    path: '/newsDetail/:id?',
    component: () => import('../views/details/NewsDetail.vue'),
  },
  //分会详情
  {
    path: '/branchDetail/:id?',
    component: () => import('../views/details/BranchDetail.vue'),
  },
  //会员详情
  {
    path: '/vipDetail/:id?',
    component: () => import('../views/details/VipDetail.vue'),
  },
  //会员名录详情
  {
    path: '/memberDetail/:id?',
    component: () => import('../views/details/MemberDetail.vue'),
  },
  //活动详情
  {
    path: '/activityDetail/:id?',
    component: () => import('../views/details/ActivityDetail.vue'),
  },
  //赋能服务详情
  {
    path: '/energizeDetail/:id?',
    name: 'energizeDetail',
    component: () => import('../views/details/EnergizeDetail.vue'),
  },
  //直播详情
  {
    path: '/liveDetail/:id?',
    name: 'liveDetail',
    component: () => import('../views/details/LiveDetail.vue'),
  },
  //协会动态
  {
    path: '/dynamic',
    name:'协会动态',
    component: () => import('../views/dynamic/Index.vue'),
    redirect: '/dynamic/construction',
    children: [{
        path: 'construction',
        name: '协会党建',
        component: () => import("../views/dynamic/Construction.vue"),
      },
      {
        path: 'news/:id?',
        name: '协会资讯',
        component: () => import("../views/dynamic/News.vue"),
      },
      {
        path: 'branch',
        name: '分会资讯',
        component: () => import("../views/dynamic/Branch.vue"),
      },
      {
        path: 'vip',
        name: '会员资讯',
        component: () => import("../views/dynamic/Vip.vue"),
      },
      {
        path: 'activity',
        name: '协会活动',
        component: () => import("../views/dynamic/Activity.vue"),
      },
      {
        path: 'live',
        name: '项目直播',
        component: () => import("../views/dynamic/Live.vue"),
      }
    ]
  },

  //协会服务
  {
    path: '/service',
    name:'协会服务',
    component: () => import('../views/service/Index.vue'),
    redirect: '/service/invest',
    children: [{
        path: 'invest',
        name: '投融服务',
        component: () => import("../views/service/Invest.vue"),
      },
      {
        path: 'energize',
        name: '赋能服务',
        component: () => import("../views/service/Energize.vue"),
      },
      {
        path: 'attract',
        name: '招商推介',
        component: () => import("../views/service/Attract.vue"),
      },
    ]
  },
  //入会指南
  {
    path: '/guide',
    name:'入会指南',
    component: () => import('../views/guide/Index.vue'),
    redirect: '/guide/introduce',
    children: [{
        path: 'introduce',
        name: '入会介绍',
        component: () => import("../views/guide/Introduce.vue"),
      },
      {
        path: 'vip',
        name: '会员名录',
        component: () => import("../views/guide/Vip.vue"),
      },
      {
        path: 'branch',
        name: '分会布局',
        component: () => import("../views/guide/Branch.vue"),
      },
    ]

  },
  //关于我们
  {
    path: '/about',
    name:'关于我们',
    component: () => import('../views/about/Index.vue'),
    redirect: '/about/introduce',
    children: [{
        path: 'introduce',
        name: '协会介绍',
        component: () => import("../views/about/Introduce.vue"),
      },
      {
        path: 'organization',
        name: '组织架构',
        component: () => import("../views/about/Organization.vue"),
      },
      {
        path: 'regulations',
        name: '协会章程',
        component: () => import("../views/about/Regulations.vue"),
      },
      {
        path: 'contact',
        name: '联系我们',
        component: () => import("../views/about/Contact.vue"),
      },
    ]
  },

]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router